package com.cskaoyan.processor;

import com.cskaoyan.util.ProxyUtil;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author stone
 * @date 2022/10/03 22:05
 */
@Component
public class ServiceProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean.getClass().getName().endsWith("ServiceImpl")) {
            Object serviceProxy = ProxyUtil.getServiceProxy(bean);
            return serviceProxy;
        }
        return bean;
    }
}
